/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bash.carrep.dao.enties;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bash
 */
@Entity
@Table(name = "automobile", catalog = "carrepdb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Automobile.findAll", query = "SELECT a FROM Automobile a"),
    @NamedQuery(name = "Automobile.findByIdAutomobile", query = "SELECT a FROM Automobile a WHERE a.idAutomobile = :idAutomobile"),
    @NamedQuery(name = "Automobile.findByImmat", query = "SELECT a FROM Automobile a WHERE a.immat = :immat"),
    @NamedQuery(name = "Automobile.findByPaysOrigine", query = "SELECT a FROM Automobile a WHERE a.paysOrigine = :paysOrigine")})
public class Automobile implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "idAutomobile", nullable = false)
    private Integer idAutomobile;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 8)
    @Column(name = "immat", nullable = false, length = 8)
    private String immat;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "PaysOrigine", nullable = false, length = 45)
    private String paysOrigine;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idAutomobile")
    private List<Declaration> declarationList;
    @JoinColumn(name = "IdModele", referencedColumnName = "idModeleAuto", nullable = false)
    @ManyToOne(optional = false)
    private ModeleAuto idModele;

    public Automobile() {
    }

    public Automobile(Integer idAutomobile) {
        this.idAutomobile = idAutomobile;
    }

    public Automobile(Integer idAutomobile, String immat, String paysOrigine) {
        this.idAutomobile = idAutomobile;
        this.immat = immat;
        this.paysOrigine = paysOrigine;
    }

    public Integer getIdAutomobile() {
        return idAutomobile;
    }

    public void setIdAutomobile(Integer idAutomobile) {
        this.idAutomobile = idAutomobile;
    }

    public String getImmat() {
        return immat;
    }

    public void setImmat(String immat) {
        this.immat = immat;
    }

    public String getPaysOrigine() {
        return paysOrigine;
    }

    public void setPaysOrigine(String paysOrigine) {
        this.paysOrigine = paysOrigine;
    }

    @XmlTransient
    public List<Declaration> getDeclarationList() {
        return declarationList;
    }

    public void setDeclarationList(List<Declaration> declarationList) {
        this.declarationList = declarationList;
    }

    public ModeleAuto getIdModele() {
        return idModele;
    }

    public void setIdModele(ModeleAuto idModele) {
        this.idModele = idModele;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAutomobile != null ? idAutomobile.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Automobile)) {
            return false;
        }
        Automobile other = (Automobile) object;
        if ((this.idAutomobile == null && other.idAutomobile != null) || (this.idAutomobile != null && !this.idAutomobile.equals(other.idAutomobile))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bash.carrep.dao.enties.Automobile[ idAutomobile=" + idAutomobile + " ]";
    }
    
}
